package com.yhq.spring.event.order;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hqyin
 * @date 2023/3/13 3:08 下午
 */
@RestController
@Slf4j
public class OrderEventController {
    @Autowired
    private ApplicationContext applicationContext;

    @GetMapping("/order/event/{msgId}")
    public String pushEvent(@PathVariable String msgId){
        OrderEvent event = new OrderEvent();
        event.setMsgId(msgId);
        event.setType("add");
        applicationContext.publishEvent(event);
        log.info("=======>publish order event");
        return "success";
    }
}
